﻿
using System.Configuration;
using System.Data;
/**
 * The Product class
 * 
 * This is just to simulate some way of accessing data about  our products
 */
using System.Data.SqlClient;
public class Product
{

    public int Id { get; set; }
    public int Price { get; set; }
    public string Description { get; set; }
    SqlConnection con;
    private string Connect = ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString;
    public Product(int id)
    {
        this.Id = id;
        string sql = "select * from SanPham where  MaSP='" + id + "'";
        con = new SqlConnection(Connect);
        con.Open();
        SqlCommand command = new SqlCommand(sql, con);
        SqlDataReader reader = command.ExecuteReader();
        reader.Read();
        this.Price = int.Parse(reader["Gia"].ToString());
        this.Description = reader["Mota"].ToString();
    }

}
